﻿@model IEnumerable<Navigation>
@{
    ViewBag.Title = "导航设置";
}

<a class="btn btn-primary mb-3" asp-action="NavigationEdit"><i class="fa fa-plus"></i> 新增导航</a>

<table class="table table-hover">
    <thead>
        <tr>
            <th>编号</th>
            <th>排序</th>
            <th>名称</th>
            <th>URL</th>
            <th>启用</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.Id</td>
                <td>@item.OrderNo</td>
                <td>@item.Name</td>
                <td>@item.Url</td>
                <td>@item.Enabled.ToTrueFalseBadge()</td>
                <td>
                    <a asp-action="NavigationEdit" asp-route-id="@item.Id"><i class="fa fa-edit"></i> 编辑</a>

                    <a href="javascript:remove('@item.Id');"><i class="fa fa-trash"></i> 删除</a>
                </td>
            </tr>
        }
    </tbody>
</table>

@section scripts{
    <script type="text/javascript">
        function remove (id){
            if (confirm('确定删除吗？')) {
                $.ajax({
                    url: '@Url.Action("NavigationDelete")',
                    method: 'post',
                    data: { id: id },
                    success: function () {
                        location.reload();
                    },
                    error: function (data) {
                        alert(data.responseText);
                    }
                });
            }
        }
    </script>
}